home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------*/
- /* */
- /* SCRLWIN.H */
- /* */
- /* Header file for Scrollers and ScrollableText */
- /* */
- /*------------------------------------------------------------------------*/
-
- #if !defined( SCRLWIN_H )
- #define SCRLWIN_H
-
- #include "textwin.h"
-
- /*------------------------------------------------------------------------*/
- /* */
- /* class Scroller */
- /* */
- /* Base class for HScroller and VScroller. Provides basic */
- /* implementation of scrolling. */
- /* */
- /*------------------------------------------------------------------------*/
-
- class Scroller : public virtual WinData
- {
- protected:
- enum Type { Horz = SB_HORZ, Vert = SB_VERT };
- Scroller( Type which ) : Which( which ), Pos(0) {}
- long OnScroll( unsigned );
- virtual int GetPageSize() const = 0;
- int GetPos() const { return Pos; }
- void SetTextSize( int );
- void SetWinSize( int );
- private:
- int Pos;
- int TextSize;
- Type Which;
- };
-
- /*------------------------------------------------------------------------*/
- /* */
- /* class VScroller */
- /* */
- /* Mixin class to handle vertical scrolling */
- /* */
- /*------------------------------------------------------------------------*/
-
- class VScroller : public Scroller, public virtual Dispatcher
- {
- public:
- static void Register( UINT m, FuncType t, DispatchRecord<VScroller>::VoidFunc p )
- { Map.add( DispatchRecord<VScroller>( m, t, p ) ); }
- protected:
- VScroller() : Scroller( Vert )
- { RegisterProc( WM_VSCROLL, &VScroller::OnScroll ); }
- long OnScroll( unsigned where ) { return Scroller::OnScroll( where ); }
- int GetPageSize() const { return GetWinHeight()/GetCharHeight(); }
- virtual int Dispatch( UINT, UINT, LONG, LONG& );
- private:
- static BI_SVectorImp<DispatchRecord<VScroller> > Map;
- };
-
-
- /*------------------------------------------------------------------------*/
- /* */
- /* class HScroller */
- /* */
- /* Mixin class to handle horizontal scrolling */
- /* */
- /*------------------------------------------------------------------------*/
-
- class HScroller : public Scroller, public virtual Dispatcher
- {
- public:
- static void Register( UINT m, FuncType t, DispatchRecord<HScroller>::VoidFunc p )
- { Map.add( DispatchRecord<HScroller>( m, t, p ) ); }
- protected:
- HScroller() : Scroller( Horz )
- { RegisterProc( WM_HSCROLL, &HScroller::OnScroll ); }
- long OnScroll( unsigned where ) { return Scroller::OnScroll( where ); }
- int GetPageSize() const { return GetWinWidth()/GetCharWidth(); }
- virtual int Dispatch( UINT, UINT, LONG, LONG& );
- private:
- static BI_SVectorImp<DispatchRecord<HScroller> > Map;
- };
-
- /*------------------------------------------------------------------------*/
- /* */
- /* class ScrollableText */
- /* */
- /* Mixes TextWindow, VScroller, and HScroller to provide */
- /* a scrollable text window. */
- /* */
- /*------------------------------------------------------------------------*/
-
- class ScrollableText : public TextWindow,
- private VScroller,
- private HScroller
- {
- public:
- ScrollableText()
- {
- VScroller::SetTextSize( Lines() );
- HScroller::SetTextSize( Width() );
- }
- void Create( HWND handle, int show, DWORD flags = 0 )
- { TextWindow::Create( handle, show, flags | WS_VSCROLL | WS_HSCROLL ); }
- protected:
- int GetXPos() const { return HScroller::GetPos(); }
- int GetYPos() const { return VScroller::GetPos(); }
- void Resized()
- {
- VScroller::SetWinSize( GetWinHeight()/GetCharHeight()-1 );
- HScroller::SetWinSize( GetWinWidth()/GetCharWidth()-1 );
- }
- virtual int Dispatch( UINT, UINT, LONG, LONG& );
- };
-
- #endif // SCRLWIN_H
-